<?php
/**
 * Created by PhpStorm.
 * User: yf
 * Date: 2017/9/13
 * Time: 上午12:03
 */

namespace App\Controller\Rest;


use Core\AbstractInterface\AbstractREST;
use Core\Http\Message\Status;
use Core\Swoole\AsyncTaskManager;
use App\Model\TaskBean;
use App\Model\Queue;
use Core\Component\ShareMemory;
use App\Utility\SysConst;

class Index extends AbstractREST
{


    function GETAddTask() {

    }

    function GETStatus(){
        $num = ShareMemory::getInstance()->get(SysConst::TASK_RUNNING_NUM);
        $this->response()->writeJson(200,array(
            "taskRuningNum"=>$num
        ));
    }

    function onRequest($actionName) {

    }

    function onWorkerStart(swoole_server $serv, $worker_id)
    {
        $this->response()->write("onWorkerStart");
        $serv->task("taskcallback");
    }



    function actionNotFound($actionName = null, $arguments = null)
    {
        // TODO: Implement actionNotFound() method.
        $this->response()->withStatus(Status::CODE_NOT_FOUND);
    }

    function afterAction()
    {
        // TODO: Implement afterAction() method.
    }

    function GETIndex(){


        $this->response()->write("this is REST GET Index222333");
    }
    function POSTIndex(){
        $this->response()->write("this is REST POST Index");
    }

    function GETTest(){
        $this->response()->write("this is REST GET test");
    }
    function POSTTest(){
        $this->response()->write("this is REST POST test");
    }

}